<?php if(!empty($results)) { ?>
<div class="box">
    
    <?php if($this->uri->segment(1) <> '' && $this->uri->segment(1) <> '/'){ ?>
    <ol class="breadcrumb">
        <li><a href="<?php echo get_base_url(); ?>" title="<?php echo DEFAULT_COMPANY; ?>"><?php echo __('IP_home_page'); ?></a></li>
        <?php if($category_id<>0){ ?><li><a href="<?php echo get_url_by_lang(get_language(),'products'); ?>" title="<?php echo __('IP_products'); ?>"><?php echo __('IP_products'); ?></a></li><?php } ?>
        <li class="active"><?php echo (isset($category))?$category:''; ?></li>
    </ol>
    <?php } ?>
    
    <?php foreach($results as $k => $result){ 
        if(SLUG_ACTIVE==0){
            $more_link = get_base_url() . url_title(trim($result['category']), 'dash', TRUE) . '-p' . $result['id'];
        }else{
            $more_link = get_base_url() . $result['category_slug'];
        }
    ?>
    <?php if(!empty($result['products'])){ ?>
    <h3><a href="<?php echo $more_link; ?>"><?php echo $result['category']; ?></a><span class="pull-right"><a href="<?php echo $more_link; ?>">Xem tiếp &#187;</a></span></h3>
        
    <div class="grid">
        <div class="row">
        <?php foreach($result['products'] as $key => $product){
            if(SLUG_ACTIVE==0){
                $uri = get_base_url() . url_title(trim($product->product_name), 'dash', TRUE) . '-ps' . $product->id;
            }else{
                $uri = get_base_url() . $product->slug;
            }
            $image = is_null($product->image_name) ? base_url().'images/no-image.png' : base_url().'images/products/thumbnails/'.$product->image_name;
            $product_name = limit_text($product->product_name, 50);
            $price = $product->price != 0 ? get_price_in_vnd($product->price) . ' ₫' : get_price_in_vnd($product->price);        
            $product_unit   = ($product->unit != NULL && $product->unit != '') ? '/' . $product->unit : '';
        ?>
        <div class="col-sm-3 grid_item">
            <div class="thumbnail">
                <a href="<?php echo $uri; ?>" title="<?php echo $product->product_name; ?>">
                    <img title="<?php echo $product->product_name; ?>" alt="<?php echo $product->product_name; ?>" src="<?php echo $image; ?>" >
                </a>
                <div class="caption">
                    <p class="grid_title"><a href="<?php echo $uri; ?>" title="<?php echo $product->product_name; ?>"><?php echo $product_name; ?></a></p>
<!--                    <p class="grid_price">
                        <strong><?php // echo $price; ?></strong><?php // echo ($price<>0)?$product_unit:'';?>
                    </p>-->
                    <p><strong>Hãng: </strong><?php echo $product->trademark_name; ?></p>
                    <p><strong>Xuất xứ: </strong><?php echo $product->origin_name; ?></p>
                </div>
            </div>
        </div>
        <?php } ?>
        </div>        
    </div>
    <?php } ?>
<?php } ?>
</div>
<?php } ?>